using ObjFileLoader.Data.DataStore;
using ObjFileLoader.TypeParsers;

namespace ObjFileLoader.Loaders
{
	public class ObjLoaderFactory : IObjLoaderFactory
	{
		public IObjLoader Create()
		{
			return Create(new MaterialStreamProvider());
		}

		public IObjLoader Create(IMaterialStreamProvider materialStreamProvider)
		{
			DataStore dataStore = new DataStore();
			FaceParser faceParser = new FaceParser(dataStore);
			GroupParser groupParser = new GroupParser(dataStore);
			NormalParser normalParser = new NormalParser(dataStore);
			TextureParser textureParser = new TextureParser(dataStore);
			VertexParser vertexParser = new VertexParser(dataStore);
			MaterialLibraryParser materialLibraryParser = new MaterialLibraryParser(new MaterialLibraryLoaderFacade(new MaterialLibraryLoader(dataStore), materialStreamProvider));
			UseMaterialParser useMaterialParser = new UseMaterialParser(dataStore);
			return new ObjLoader(dataStore, faceParser, groupParser, normalParser, textureParser, vertexParser, materialLibraryParser, useMaterialParser);
		}
	}
}
